We can add JavaScript in the body with onload, we'll write our code into the double quotes, but the onload don't suport functions or advanced js, like the next example:
<body onload="alert('Hello from the body onload!')">
//On load means, wherever the js is, it's called
You can add js, insade the html, just adding the tag "script", and inside him all your wantend code
<scrip>
//Here you can add your code like this
function hiScript() {
alert("Hello from the script tag!");
};
</scrip>
You can add js, from an external js file, white the script tag, but, adding some atributes.
JUST ONE BEST PRACTICE, the js are adding at the bottom of the body, cause on that don't will be crashed with the inexisting html tags or css, on that place, the js will be played until all the html struture is loaded, and it will give an fast aparience
<scrip src="./static/js/index.js" charset="utf-8" ></scrip>